import React, { Component } from 'react';
import { Form, Input, Button } from 'antd';

export default class Hedaer extends Component {
    constructor(props){
        super(props);
        this.state = {
            name: '',
            address: ''
        }
    }
    inputChange = (e) => {
        this.setState({name: e.target.value});
    }
    inputChange2 = (e) => {
        this.setState({address: e.target.value});
    }
    handleClick = () => {
        this.props.tomsg({name: this.state.name, address:this.state.address});
    }
    handleClickTwo = () => {
        this.setState({name: ''});
        this.setState({address: ''});
        this.props.tomsg({name: '', address: ''});
    }
    render() {
        return (
            <Form name="horizontal_login" layout="inline">
                <Form.Item
                    name="username"
                    label={this.props.name[0]}
                >
                    <Input onChange={this.inputChange} value={this.state.name}  placeholder="请输入用户名" />
                </Form.Item>
                <Form.Item
                    name="password"
                    label={this.props.name[1]}
                >
                    <Input  onChange={this.inputChange2} value={this.state.address} placeholder="请输入地址" />
                </Form.Item>
                <Form.Item
                    name="submit"
                >
                    <Button onClick={this.handleClick} type="primary" >搜索</Button>           
                    <Button style={{marginLeft: '15px'}} onClick={this.handleClickTwo}>重置</Button>    
                </Form.Item>
            </Form>
        )
    }
}